package com.example.toy.core.reader;

import com.example.toy.core.dataset.BigCollection;
import com.example.toy.core.filter.ToyFilter;
import com.example.toy.core.record.ToyRecord;
import com.example.toy.core.table.ToyTableMeta;
import com.example.toy.core.utils.VersionHelper;
import com.example.toy.core.version.ToyVersion;
import lombok.SneakyThrows;
import org.apache.avro.Schema;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.util.List;

public class DefaultToyBaseFileReader implements ToyFileReader {

  private final Path path;
  private final ToyTableMeta tableMeta;
  private final ToyVersion version;
  private final Schema schema;

  public DefaultToyBaseFileReader(ToyTableMeta meta, Path path) {
    this.path = path;
    this.tableMeta = meta;
    this.version = VersionHelper.fromPath(path);

    /** 由于当前是表基本文件，所以表的结构是固定的 */
    this.schema = meta.getCommitView().getTableSchema(version);
  }

  @SneakyThrows
  @Override
  public List<ToyRecord> read(ToyFilter... filters) {
    FileSystem fs = path.getFileSystem(tableMeta.getHadoopConf());
    return null;
  }

  @Override
  public BigCollection<ToyRecord> parRead(ToyFilter... filters) {

    return null;
  }
}
